-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Propose new KVM driver based on KVMi subsystem #844
Conversation
Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
This will enable querying all the registers in one step.
Implement a new KVM driver specific MSR translation. This reverts commit f75a73c.
This is still quite experimental. To be more specific, I think kvm_set_vcpureg is likely to be broken. The reason for this is that the kernel only supports setting all the registers at once and for us to be able to set only a single register we need to retrieve the old values first. Of course, both of these operations need to be done without the vcpu continuing execution while the operations are happening. Maybe we should explicitly pause the vcpu before the operations.
Apparently I had broken the kvm.h header when picking chunks for the previous commit. Sorry for that.
kvmi_uninit was called twice leading to a double free bug if unix socket connection errored. This fixes the problem by manually setting the kvmi pointer to NULL as kvmi_uninit checks for that.
This replaces the hard coded /var/run/testing.sock path with a configurable option.
…igurable socket path.
This commit removes all the other access methods from the kvm driver and only leaves the new kvmi based one. Now `--enable-kvm` implies kvmi.
Kernel API ---------- Noteworthy changes - different values for KVMI_EVENT_* (we have KVMI_EVENT_X and KVMI_EVENT_X_FLAG) - kvmi_event_page_fault renamed to kvmi_event_pf + a new member (shadow_gs) - KVMI_PAUSE_ALL_VCPUS command replaced KVMI_PAUSE_VCPU - kvmi_event_reply has a new member (the event id) - kvmi_get_guest_info_reply extended the vcpu_count member to u32 New - two new VM events: KVMI_EVENT_CREATE_VCPU and KVMI_EVENT_UNHOOK Library API ----------- Noteworthy changes - the structures exchanged during handshake changed - kvmi_domain_close() has a second parameter (to shutdown the socket) - the events received while waiting a command' reply are saved for later processing (kvmi_pop_event) - the event callback has been removed; the events should be accesed with kvmi_wait_event()+kvmi_pop_event() New - a handshake callback can be supplied to kvmi_init_* functions - a logging callback can be set (kvmi_set_log_cb) to receive debug/info/warning/error messages from libkvmi - reads and writes have a 15 seconds timeout - all commands (send+recv) and event replies (send) are synchronized with a mutex Signed-off-by: Mihai Donțu <mdontu@bitdefender.com> Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com> Signed-off-by: Nicușor Cîțu <ncitu@bitdefender.com> Signed-off-by: Mircea Cîrjaliu <mcirjaliu@bitdefender.com>
The libkvmi API (RFC v5) changed two functions used by this driver: - kvmi_init_unix_socket() - kvmi_domain_close() Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
In order to silence: warning: implicit declaration of function ‘vasprintf’ [-Wimplicit-function-declaration] Signed-off-by: Adalbert Lazăr <alazar@bitdefender.com>
@tklengyel can you trigger the jenkins also ? |
@drakvuf-jenkins retest this please |
This is looking good to me, I only spotted some minor things that really aren't blockers. Lots of kudos @mtarral for getting this done! 🥇 🥳 |
@tklengyel thanks for you review, I've just fixed the minor issues you have found. I'm excited to bring this new driver to the LibVMI community ! |
@Wenzel Thank you for addressing my license and header-related concerns. There are a few remaining Sandia references in libvmi/driver/kvm files though that need attention. |
According to @tklengyel's comment: #844 (comment) or did you mean that since the files have changed so much, the Sandia license wasn't applying anymore ? |
@Wenzel Ah, disregard my comment about the other Sandia lines. The notices I cited do indeed need to stay in place. |
Echoing Tamas: I'm very happy to see this come to fruition. Thanks to all Mathieu especially but also to the substantial set of reviewers/contributors we've had on this one. |
Thanks @smaresca :) 👌 |
This PR proposes a brand new KVM driver, based on the experimental KVMi subsystem currently being developed by BitDefender.
The driver's code has been splitted:
kvm_legacy.c
: legacy kvm driver (GDB and qemu memaccess patch)kvm.c
the new driver based in KVMikvm_common.c
: common functions share by both drivers.This PR also changes some of the examples to include a new
kvmi_socket
optional parameter.cc @tklengyel , @adlazar, @mdontu
Fixes #827 , #778