From: "Tyler Hicks" code@tyhicks.com
The backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test") broke the build of the KVM selftest memslot_modification_stress_test.c source file in two ways:
- Incorrectly assumed that max_t() was defined despite commit 5cf67a6051ea ("tools/include: Add _RET_IP_ and math definitions to kernel.h") not being present - Incorrectly assumed that kvm_vm struct members could be directly accessed despite b530eba14c70 ("KVM: selftests: Get rid of kvm_util_internal.h") not being present
Backport the first commit, as it is simple enough. Work around the lack of the second commit by using the accessors to get to the kvm_vm struct members.
Note that the linux-6.0.y backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test") is fine because the two prerequisite commits, mentioned above, are both present in v6.0.
Tyler
Karolina Drobnik (1): tools/include: Add _RET_IP_ and math definitions to kernel.h
Tyler Hicks (Microsoft) (1): KVM: selftests: Fix build regression by using accessor function
tools/include/linux/kernel.h | 6 ++++++ .../selftests/kvm/memslot_modification_stress_test.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
From: Karolina Drobnik karolinadrobnik@gmail.com
commit 5cf67a6051ea2558fd7c3d39c5a808db73073e9d upstream.
Add max_t, min_t and clamp functions, together with _RET_IP_ definition, so they can be used in testing.
Signed-off-by: Karolina Drobnik karolinadrobnik@gmail.com Signed-off-by: Mike Rapoport rppt@kernel.org Link: https://lore.kernel.org/r/230fea382cb1e1659cdd52a55201854d38a0a149.164379666... [tyhicks: Backport around contextual differences due to the lack of v5.16 commit d6e6a27d960f ("tools: Fix math.h breakage"). That commit fixed a commit that was merged in v5.16-rc1 and, therefore, doesn't need to go back to the stable branches.] Signed-off-by: Tyler Hicks (Microsoft) code@tyhicks.com --- tools/include/linux/kernel.h | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index a7e54a08fb54..c2e109860fbc 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h @@ -14,6 +14,8 @@ #define UINT_MAX (~0U) #endif
+#define _RET_IP_ ((unsigned long)__builtin_return_address(0)) + #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1) @@ -52,6 +54,10 @@ _min1 < _min2 ? _min1 : _min2; }) #endif
+#define max_t(type, x, y) max((type)x, (type)y) +#define min_t(type, x, y) min((type)x, (type)y) +#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) + #ifndef roundup #define roundup(x, y) ( \ { \
From: "Tyler Hicks" code@tyhicks.com
Fix the stable backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test"), which caused memslot_modification_stress_test.c build failures due to trying to access private members of struct kvm_vm.
v6.0 commit b530eba14c70 ("KVM: selftests: Get rid of kvm_util_internal.h") and some other commits got rid of the accessors and made all of the KVM data structures public. Keep using the accessors in older kernels.
There is no corresponding upstream commit for this change.
Signed-off-by: Tyler Hicks (Microsoft) code@tyhicks.com --- tools/testing/selftests/kvm/memslot_modification_stress_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kvm/memslot_modification_stress_test.c b/tools/testing/selftests/kvm/memslot_modification_stress_test.c index 1d806b8ffee2..766c1790df66 100644 --- a/tools/testing/selftests/kvm/memslot_modification_stress_test.c +++ b/tools/testing/selftests/kvm/memslot_modification_stress_test.c @@ -72,7 +72,7 @@ struct memslot_antagonist_args { static void add_remove_memslot(struct kvm_vm *vm, useconds_t delay, uint64_t nr_modifications) { - uint64_t pages = max_t(int, vm->page_size, getpagesize()) / vm->page_size; + uint64_t pages = max_t(int, vm_get_page_size(vm), getpagesize()) / vm_get_page_size(vm); uint64_t gpa; int i;
On 12/23/22 01:09, Tyler Hicks wrote:
From: "Tyler Hicks" code@tyhicks.com
The backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test") broke the build of the KVM selftest memslot_modification_stress_test.c source file in two ways:
- Incorrectly assumed that max_t() was defined despite commit 5cf67a6051ea ("tools/include: Add _RET_IP_ and math definitions to kernel.h") not being present
- Incorrectly assumed that kvm_vm struct members could be directly accessed despite b530eba14c70 ("KVM: selftests: Get rid of kvm_util_internal.h") not being present
Backport the first commit, as it is simple enough. Work around the lack of the second commit by using the accessors to get to the kvm_vm struct members.
Note that the linux-6.0.y backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test") is fine because the two prerequisite commits, mentioned above, are both present in v6.0.
Tyler
Karolina Drobnik (1): tools/include: Add _RET_IP_ and math definitions to kernel.h
Tyler Hicks (Microsoft) (1): KVM: selftests: Fix build regression by using accessor function
tools/include/linux/kernel.h | 6 ++++++ .../selftests/kvm/memslot_modification_stress_test.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
Acked-by: Paolo Bonzini pbonzini@redhat.com
On Fri, Dec 23, 2022 at 05:45:44PM +0100, Paolo Bonzini wrote:
On 12/23/22 01:09, Tyler Hicks wrote:
From: "Tyler Hicks" code@tyhicks.com
The backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test") broke the build of the KVM selftest memslot_modification_stress_test.c source file in two ways:
- Incorrectly assumed that max_t() was defined despite commit 5cf67a6051ea ("tools/include: Add _RET_IP_ and math definitions to kernel.h") not being present
- Incorrectly assumed that kvm_vm struct members could be directly accessed despite b530eba14c70 ("KVM: selftests: Get rid of kvm_util_internal.h") not being present
Backport the first commit, as it is simple enough. Work around the lack of the second commit by using the accessors to get to the kvm_vm struct members.
Note that the linux-6.0.y backport of commit 05c2224d4b04 ("KVM: selftests: Fix number of pages for memory slot in memslot_modification_stress_test") is fine because the two prerequisite commits, mentioned above, are both present in v6.0.
Tyler
Karolina Drobnik (1): tools/include: Add _RET_IP_ and math definitions to kernel.h
Tyler Hicks (Microsoft) (1): KVM: selftests: Fix build regression by using accessor function
tools/include/linux/kernel.h | 6 ++++++ .../selftests/kvm/memslot_modification_stress_test.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
Acked-by: Paolo Bonzini pbonzini@redhat.com
Queued up, thanks!
linux-kselftest-mirror@lists.linaro.org