forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'kvm-x86-selftests-6.9' of https://github.com/kvm-x86/linux …
…into HEAD KVM selftests changes for 6.9: - Add macros to reduce the amount of boilerplate code needed to write "simple" selftests, and to utilize selftest TAP infrastructure, which is especially beneficial for KVM selftests with multiple testcases. - Add basic smoke tests for SEV and SEV-ES, along with a pile of library support for handling private/encrypted/protected memory. - Fix benign bugs where tests neglect to close() guest_memfd files.
- Loading branch information
Showing
26 changed files
with
802 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UTIL_ARCH_H | ||
#define SELFTEST_KVM_UTIL_ARCH_H | ||
|
||
struct kvm_vm_arch {}; | ||
|
||
#endif // SELFTEST_KVM_UTIL_ARCH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Macros for defining a KVM test | ||
* | ||
* Copyright (C) 2022, Google LLC. | ||
*/ | ||
|
||
#ifndef SELFTEST_KVM_TEST_HARNESS_H | ||
#define SELFTEST_KVM_TEST_HARNESS_H | ||
|
||
#include "kselftest_harness.h" | ||
|
||
#define KVM_ONE_VCPU_TEST_SUITE(name) \ | ||
FIXTURE(name) { \ | ||
struct kvm_vcpu *vcpu; \ | ||
}; \ | ||
\ | ||
FIXTURE_SETUP(name) { \ | ||
(void)vm_create_with_one_vcpu(&self->vcpu, NULL); \ | ||
} \ | ||
\ | ||
FIXTURE_TEARDOWN(name) { \ | ||
kvm_vm_free(self->vcpu->vm); \ | ||
} | ||
|
||
#define KVM_ONE_VCPU_TEST(suite, test, guestcode) \ | ||
static void __suite##_##test(struct kvm_vcpu *vcpu); \ | ||
\ | ||
TEST_F(suite, test) \ | ||
{ \ | ||
vcpu_arch_set_entry_point(self->vcpu, guestcode); \ | ||
__suite##_##test(self->vcpu); \ | ||
} \ | ||
static void __suite##_##test(struct kvm_vcpu *vcpu) | ||
|
||
#endif /* SELFTEST_KVM_TEST_HARNESS_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UTIL_ARCH_H | ||
#define SELFTEST_KVM_UTIL_ARCH_H | ||
|
||
struct kvm_vm_arch {}; | ||
|
||
#endif // SELFTEST_KVM_UTIL_ARCH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UTIL_ARCH_H | ||
#define SELFTEST_KVM_UTIL_ARCH_H | ||
|
||
struct kvm_vm_arch {}; | ||
|
||
#endif // SELFTEST_KVM_UTIL_ARCH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tools/testing/selftests/kvm/include/x86_64/kvm_util_arch.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef SELFTEST_KVM_UTIL_ARCH_H | ||
#define SELFTEST_KVM_UTIL_ARCH_H | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
struct kvm_vm_arch { | ||
uint64_t c_bit; | ||
uint64_t s_bit; | ||
int sev_fd; | ||
bool is_pt_protected; | ||
}; | ||
|
||
static inline bool __vm_arch_has_protected_memory(struct kvm_vm_arch *arch) | ||
{ | ||
return arch->c_bit || arch->s_bit; | ||
} | ||
|
||
#define vm_arch_has_protected_memory(vm) \ | ||
__vm_arch_has_protected_memory(&(vm)->arch) | ||
|
||
#endif // SELFTEST_KVM_UTIL_ARCH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.