Skip to contentSkip to conversation

Fix kvm selftest build failures in linux-5.15.y

PATCH Applied Tyler Hicks 3 participants 5 messages Dec 23, 2022 – Dec 25, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Fix kvm selftest build failures in linux-5.15.y

From: "Tyler Hicks" <[email protected]>

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(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 tools/include: Add _RET_IP_ and math definitions to kernel.h

From: Karolina Drobnik <[email protected]>

commit 5cf67a6051ea2558fd7c3d39c5a808db73073e9d upstream.

Add max_t, min_t and clamp functions, together with _RET_IP_ definition, so they can be used in testing.

[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.]

---
 tools/include/linux/kernel.h | 6 ++++++
 1 file changed, 6 insertions(+)
tools/include/linux/kernel.h +6 -0
index a7e54a08fb54..c2e109860fbc 100644
@@ -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) (                                \
 {                                                      \
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 KVM: selftests: Fix build regression by using accessor function

In reply to Tyler Hicks

From: "Tyler Hicks" <[email protected]>

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.

---
 tools/testing/selftests/kvm/memslot_modification_stress_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kvm/memslot_modification_stress_test.c +1 -1
index 1d806b8ffee2..766c1790df66 100644
@@ -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;
 
Signature · 1 line
2.34.1
maintainer Acked-by on the v1 series
#3 lore raw
In reply to Tyler Hicks
Quoted 28 lines · Tyler Hicks

From: "Tyler Hicks" <[email protected]>

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

Quoted 7 lines

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(-)
maintainer Applied
#4 lore raw
Quoted 32 lines · Paolo Bonzini
Quoted 31 lines · Tyler Hicks

From: "Tyler Hicks" <[email protected]>

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

Quoted 7 lines
Quoted 4 lines
 tools/include/linux/kernel.h                                | 6 ++++++
 .../selftests/kvm/memslot_modification_stress_test.c        | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

Queued up, thanks!

Signature · 2 lines
Thanks,
Sasha