Skip to content
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

Add support for bus lock detection (KVM_CAP_X86_BUS_LOCK_EXIT). #245

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

00xc
Copy link
Contributor

@00xc 00xc commented Nov 23, 2023

Summary of the PR

Add support for bus lock detection. The feature can be enabled via KVM_CAP_X86_BUS_LOCK_EXIT, which enables a new exit (KVM_EXIT_X86_BUS_LOCK) and a new flag (KVM_RUN_X86_BUS_LOCK) in the kvm_run->flags field.

Add two tests as well to verify that enabling the feature works

Requirements

  • All commits in this PR are signed (with git commit -s), and the commit
    message has max 60 characters for the summary and max 75 characters for each
    description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@JonathanWoollett-Light
Copy link

@00xc Can you please resolve the merge conflicts, after this LGTM.

Introduce a new method to get an immutable reference to the kvm_run
struct. Replace uses of `as_mut_ref()` with `as_ref()` where possible.

Signed-off-by: Carlos López <[email protected]>
Add support for bus lock detection. The feature can be enabled via
KVM_CAP_X86_BUS_LOCK_EXIT, which enables a new exit
(KVM_EXIT_X86_BUS_LOCK) and a new flag (KVM_RUN_X86_BUS_LOCK) in the
kvm_run->flags field.

Add two tests as well to verify that enabling the feature works.

Signed-off-by: Carlos López <[email protected]>
@00xc
Copy link
Contributor Author

00xc commented Dec 15, 2023

Rebased on main and fixed conflicts.

args: [args as u64, 0, 0, 0],
..Default::default()
};
vm.enable_cap(&cap).unwrap_err();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also check the inner error? Maybe using .errno() like in other tests.

///
/// See the API documentation for `KVM_CAP_X86_BUS_LOCK_EXIT`.
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
pub fn bus_lock_detected(&self) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would prefix the name with is_ (is_bus_...) to match the naming conventions used for such functions.

Also, can we add a test for it?

@roypat roypat mentioned this pull request Dec 22, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants